package com.tuanzi.loan.web.bean.application;

import com.tuanzi.loan.business.entity.application.LoanApplicationExportGroupPage;
import com.tuanzi.loan.business.service.application.LoanApplicationExportGroupPageService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.util.List;

/**
 * @Auther: hequnayu
 * @Date: 2019/7/30 14:21
 * @Description:
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class LoanApplicationExportGroupPageListBean extends JSFListingBean {

    private static final long serialVersionUID = 4771150548357069223L;

    @Autowired
    private LoanApplicationExportGroupPageService bannerPageService;

    private List<LoanApplicationExportGroupPage> bannerPageList;

    @PostConstruct
    private void init() {
        bannerPageList = bannerPageService.findAll();
    }

    public String onAdd() {
        return redirect("/views/application/page/info.xhtml");
    }

    public String onEdit(String id) {
        return redirect("/views/application/page/info.xhtml?id=" + id);
    }

    public void onDelete(Long id){
        bannerPageService.delete(id);
        bannerPageList = bannerPageService.findAll();
        addSuccessfullyMessage();
    }
}
